/*
 * Copyright (c) 2022 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef DATASHARE_PREDICATES_H
#define DATASHARE_PREDICATES_H

#include "datashare_abs_predicates.h"

#include <string>

#include "datashare_predicates_object.h"
#include "datashare_predicates_objects.h"

namespace OHOS {
namespace DataShare {
class DataSharePredicates : public DataShareAbsPredicates {
public:
    DataSharePredicates();
    explicit DataSharePredicates(const std::list<OperationItem> &operList);
    ~DataSharePredicates();
    DataSharePredicates *EqualTo(const std::string &field, const DataSharePredicatesObject &value) override;
    DataSharePredicates *NotEqualTo(const std::string &field, const DataSharePredicatesObject &value) override;
    DataSharePredicates *GreaterThan(const std::string &field, const DataSharePredicatesObject &value) override;
    DataSharePredicates *LessThan(const std::string &field, const DataSharePredicatesObject &value) override;
    DataSharePredicates *GreaterThanOrEqualTo(const std::string &field,
        const DataSharePredicatesObject &value) override;
    DataSharePredicates *LessThanOrEqualTo(const std::string &field, const DataSharePredicatesObject &value) override;
    DataSharePredicates *In(const std::string &field, const DataSharePredicatesObjects &values) override;
    DataSharePredicates *NotIn(const std::string &field, const DataSharePredicatesObjects &values) override;
    DataSharePredicates *BeginWrap() override;
    DataSharePredicates *EndWrap() override;
    DataSharePredicates *Or() override;
    DataSharePredicates *And() override;
    DataSharePredicates *Contains(const std::string &field, const std::string &value) override;
    DataSharePredicates *BeginsWith(const std::string &field, const std::string &value) override;
    DataSharePredicates *EndsWith(const std::string &field, const std::string &value) override;
    DataSharePredicates *IsNull(const std::string &field) override;
    DataSharePredicates *IsNotNull(const std::string &field) override;
    DataSharePredicates *Like(const std::string &field, const std::string &value) override;
    DataSharePredicates *Unlike(const std::string &field, const std::string &value) override;
    DataSharePredicates *Glob(const std::string &field, const std::string &value) override;
    DataSharePredicates *Between(const std::string &field, const std::string &low, const std::string &high) override;
    DataSharePredicates *NotBetween(const std::string &field, const std::string &low, const std::string &high) override;
    DataSharePredicates *OrderByAsc(const std::string &field) override;
    DataSharePredicates *OrderByDesc(const std::string &field) override;
    DataSharePredicates *Distinct() override;
    DataSharePredicates *Limit(const int number, const int offset) override;
    DataSharePredicates *GroupBy(const std::vector<std::string> &fields) override;
    DataSharePredicates *IndexedBy(const std::string &indexName) override;
    DataSharePredicates *KeyPrefix(const std::string &prefix) override;
    DataSharePredicates *InKeys(const std::vector<std::string> &keys) override;
    const std::list<OperationItem>& GetOperationList() const override;
    std::string GetWhereClause() const override;
    int SetWhereClause(const std::string &whereClause) override;
    std::vector<std::string> GetWhereArgs() const override;
    int SetWhereArgs(const std::vector<std::string> &whereArgs) override;
    std::string GetOrder() const override;
    int SetOrder(const std::string &order) override;
    SettingMode GetSettingMode() const override;
    void SetSettingMode(const SettingMode &settingMode);

private:
    void SetOperationList(OperationType operationType, const DataSharePredicatesObjects &param);
    void SetOperationList(OperationType operationType, const DataSharePredicatesObject &param1,
        const DataSharePredicatesObjects &param2);
    void SetOperationList(OperationType operationType, const DataSharePredicatesObject &para1 = {},
        const DataSharePredicatesObject &para2 = {}, const DataSharePredicatesObject &para3 = {});
    void ClearQueryLanguage();
    std::list<OperationItem> operationList_;
    std::string whereClause_;
    std::vector<std::string> whereArgs_;
    std::string order_;
    SettingMode settingMode_ = {};
};
} // namespace DataShare
} // namespace OHOS
#endif